package com.wondertek.poms.dao.repo;

import com.wondertek.poms.dao.po.ContentWhite;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * <p><b>IContentWhiteDao Description:</b> 白名单表Dao 执行白名单表的查询、修改、新增、删除操作</p>
 * <p>@author 窦再兴</p>
 * <p><b>DATE</b> 2020-12-03 10:19:26</p>
 */
public interface IContentWhiteDao extends JpaRepository<ContentWhite, Long> {

	@Query(value = "select count(*) from CONTENT_WHITE c where c.deleted = 0 and c.CONTENT_ID = ?1 and c.PRD_INFO_ID = ?2",
			nativeQuery = true)
	Object findCountByContentIdAndPackageId(String contentId, Long packageId);

	/**
	 *<p><b>Title:</b> findCountByContentIdAndPrdInfoPackageId </p>
	 *<p><b>Description:</b> 功能描述 </p>
	 *@author gaozhengxing gaozhenghang@wondertek.com.cn
	 *@date 2021/1/29 10:32
	 *@param contentId 内容id
	 *@param packageId 商品包id
	 *@return 如果该商品包有二级产品,且该二级产品下有别的商品包的数量
	 */
	@Query(value = "select cw.* from PRD_INFO pi ,CONTENT_WHITE cw " +
			" where pi.PRODUCT_INFO_PACKAGE_ID=cw.PACKAGE_ID" +
			" and cw.deleted = 0 and cw.CONTENT_ID = ?1 and pi.PRDINFOID=?2",
			nativeQuery = true)
	List<ContentWhite> findCountByContentIdAndPrdInfoPackageId(String contentId, Long packageId);

	List<ContentWhite>  findAllByContentIdAndPackageId(String contentId, Long packageId);

}
